package fr.ifsic.film.client.ui;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

import fr.ifsic.film.client.FilmProject;

public abstract class NouveauType extends VerticalPanel {
	protected Label lblTitle;
	protected VerticalPanel verticalPanel = new VerticalPanel();
	HorizontalPanel horizontalPanel = new HorizontalPanel();
	protected Button annuler = new Button("Retour");
	protected Button confirmer = new Button("Confirmer");

	public NouveauType(String title) {
		lblTitle = new Label(title);

		add(verticalPanel);
		verticalPanel.add(lblTitle);
		verticalPanel.setCellHorizontalAlignment(lblTitle,
				HasHorizontalAlignment.ALIGN_CENTER);

		add(horizontalPanel);

		annuler.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				annuler();
			}
		});

		confirmer.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				confirmer();
			}
		});
	}

	private void annuler() {
		FilmProject.changePage(FilmProject.accueil);
	}

	protected void confirmer() {
		FilmProject.changePage(FilmProject.accueil);
	}
}
